using System.IO;
using System.Text;
using System.Xml.Serialization;

namespace External.Controls.Helpers
{
    public static class Helper
    {
        public static string Serialize<T>(this T obj)
        {
            XmlSerializer s = new XmlSerializer(typeof(T));
            TextWriter w = new StringWriter(new StringBuilder());
            s.Serialize(w, obj);
            return w.ToString();
        }

        public static T Deserialize<T>(this string content)
        {
            XmlSerializer s = new XmlSerializer(typeof(T));
            TextReader r = new StringReader(content);
            return (T)s.Deserialize(r);
        }
    }
}